<#include "macrosDisplay.ftl">
<#include "macrosLoops.ftl">
<#include "permissions-macro.ftl">

			<h:outputText value="Tab Permissions" />
			<h:panelGroup>
				<h:panelGrid columns="2" columnClasses="audit-th,audit-td">
<@TabsLoop>
					<h:outputText value="${tab.name} Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.${tab.name}']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.${tab.name}']</@hb>" />
					
</@TabsLoop>
					<h:outputText value="Tasks Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.tasks']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.tasks']</@hb>" />
										
					<h:outputText value="Reports Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.reports']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.reports']</@hb>" />
										
					<h:outputText value="Preferences Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.preferences']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.preferences']</@hb>" />

					<h:outputText value="Import Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.import']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.import']</@hb>" />
					
					<h:outputText value="Admin Tab"/>
					<h:selectBooleanCheckbox rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.admin']</@hb>" />
					<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['tab.admin']</@hb>" />
				</h:panelGrid>
			</h:panelGroup>
			
			<h:outputText value="Object Permissions" />
			<h:panelGroup>
				<h:panelGrid columns="5" columnClasses="audit-th,audit-td">
				<#assign tabcounter = 0><@TabsLoop><#assign tabcounter = tabcounter + 1>				
					<h:outputText styleClass="bold" value="${tab.name} Tab" />
					
					<h:panelGroup>
						<#-- View -->
						<h:outputLabel styleClass="bold" value="View:"/>
						<h:selectBooleanCheckbox onclick="makeCheck(this);" styleClass="tab${tabcounter}view" rendered="<@hb>roleHandler.edit</@hb>" value="false" rendered="<@hb>roleHandler.edit</@hb>"/>
						<h:outputText value="&nbsp;" escape="false" rendered="<@hb>!roleHandler.edit</@hb>" />
					</h:panelGroup>
					
					<h:panelGroup>
						<#-- Edit -->
						<h:outputLabel styleClass="bold" value="Edit:"/>
						<h:selectBooleanCheckbox onclick="makeCheck(this);" styleClass="tab${tabcounter}edit" rendered="<@hb>roleHandler.edit</@hb>" value="false" rendered="<@hb>roleHandler.edit</@hb>"/>
						<h:outputText value="&nbsp;" escape="false" rendered="<@hb>!roleHandler.edit</@hb>" />
					</h:panelGroup>
						
					<h:panelGroup>
						<#-- Add -->
						<h:outputLabel styleClass="bold" value="Add:"/>
						<h:selectBooleanCheckbox onclick="makeCheck(this);" styleClass="tab${tabcounter}add" rendered="<@hb>roleHandler.edit</@hb>" value="false" rendered="<@hb>roleHandler.edit</@hb>"/>
						<h:outputText value="&nbsp;" escape="false" rendered="<@hb>!roleHandler.edit</@hb>" />
					</h:panelGroup>
											
					<h:panelGroup>
						<#-- Delete -->
						<h:outputLabel styleClass="bold" value="Delete:"/>
						<h:selectBooleanCheckbox onclick="makeCheck(this);" styleClass="tab${tabcounter}del" rendered="<@hb>roleHandler.edit</@hb>" value="false" rendered="<@hb>roleHandler.edit</@hb>"/>
						<h:outputText value="&nbsp;" escape="false" rendered="<@hb>!roleHandler.edit</@hb>" />
					</h:panelGroup>
					
					<@TabsEntityRefLoop tab>
					<@isNotAbstract entity>
					
						<h:outputText value="${entity.displayName}"/>
						<h:panelGroup>
							<#-- View -->
							<h:outputLabel for="${entity.entityName}_view" value="View:"/>
							<h:selectBooleanCheckbox id="${entity.entityName}_view" styleClass="tab${tabcounter}view" rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.view']</@hb>" />
							<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.view']</@hb>" />						
						</h:panelGroup>
						
						<h:panelGroup>
							<#-- Edit -->
							<h:outputLabel for="${entity.entityName}_edit" value="Edit:"/>
							<h:selectBooleanCheckbox id="${entity.entityName}_edit" styleClass="tab${tabcounter}edit" rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.edit']</@hb>" />
							<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.edit']</@hb>" />
						</h:panelGroup>
							
						<h:panelGroup>						
							<#-- Add -->
							<h:outputLabel for="${entity.entityName}_add" value="Add:"/>
							<h:selectBooleanCheckbox id="${entity.entityName}_add" styleClass="tab${tabcounter}add" rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.add']</@hb>" />
							<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.add']</@hb>" />
						</h:panelGroup>
											
						<h:panelGroup>							
							<#-- Delete -->
							<h:outputLabel for="${entity.entityName}_delete" value="Delete:"/>
							<h:selectBooleanCheckbox id="${entity.entityName}_delete" styleClass="tab${tabcounter}del" rendered="<@hb>roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.delete']</@hb>" />
							<h:selectBooleanCheckbox disabled="true" rendered="<@hb>!roleHandler.edit</@hb>" value="<@hb>roleHandler.current.permissions['entity.${entity.entityName}.delete']</@hb>" />	
						</h:panelGroup>

						<#-- process 1:M and 1:1 child relationships -->
						<@OTMRelationship entity>
							<@NestedPermissions entity, rel.toEntity, 1 />
						</@OTMRelationship>

						<@OTORelationship entity>
							<@NestedPermissions entity, rel.toEntity, 1 />
						</@OTORelationship>

					</@isNotAbstract>
					</@TabsEntityRefLoop>
					</@TabsLoop>
				</h:panelGrid>
			</h:panelGroup>